import {
  Controller,
  Get,
  Post,
  Body,
  Patch,
  Param,
  Delete,
  Query,
  DefaultValuePipe,
  ParseIntPipe,
  Req,
  UseGuards,
} from '@nestjs/common';
import { InventoryplanService } from 'src/service/inventoryplan.service';
import { CreateInventoryplanDto } from 'src/dto/create-inventoryplan.dto';
import { UpdateInventoryplanDto } from 'src/dto/update-inventoryplan.dto';
import { QueryInventoryplanDto } from 'src/dto/query-inventoryplan.dto';
import { AdminGuard } from 'src/guards/admin.guard';

@UseGuards(AdminGuard)
@Controller('admin/inventoryplan')
export class InventoryplanController {
  constructor(private readonly inventoryplanService: InventoryplanService) {}

  @Post()
  create(
    @Body() createInventoryplanDto: CreateInventoryplanDto,
    @Req() req: any,
  ) {
    return this.inventoryplanService.create(createInventoryplanDto, req.uid);
  }

  @Get()
  query(@Query() query: QueryInventoryplanDto) {
    return this.inventoryplanService.query(query);
  }

  @Get(':id')
  findOne(@Param('id') id: string) {
    return this.inventoryplanService.findOne(+id);
  }

  @Patch(':id')
  update(
    @Param('id') id: string,
    @Body() updateInventoryplanDto: UpdateInventoryplanDto,
    @Req() req: any,
  ) {
    return this.inventoryplanService.update(
      +id,
      updateInventoryplanDto,
      req.uid,
    );
  }

  @Delete(':id')
  remove(@Param('id') id: string) {
    return this.inventoryplanService.remove(+id);
  }

  @Post('toShipping')
  toShipping(@Body('id') id: number) {
    return this.inventoryplanService.toShipping(id);
  }

  @Post('arrive')
  arrive(@Body('id') id: number) {
    return this.inventoryplanService.arrive(id);
  }

  @Post('pay')
  pay(@Body('id') id: number) {
    return this.inventoryplanService.pay(id);
  }
}
